<template>
  <div class="qr-dialog">
    <el-dialog
      v-model="dialogVisible"
      width="300"
      :modal="false"
      align-center
      :close-on-click-modal="false"
      :close-on-press-escape="false"
      :destroy-on-close="true"
      @closed="closedHandle"
    >
      <div class="content">
        <div class="content-title">
          联系我们
        </div>
        <img
          class="content-img"
          :src="qrImgSrc"
        >
      </div>
    </el-dialog>
  </div>
</template>

<script setup lang="ts">
import { ref } from 'vue'
import qrImg from '@/assets/qr.jpg'

const qrImgSrc = qrImg

const props = defineProps({
  handleSuccess: {
    type: Function,
    default:()=>{}
  },
  handleCancel: {
    type: Function,
    default:()=>{}
  }
})

const dialogVisible = ref(true)
const clickType = ref('cancel')
const cancelType = ref('cancel')

const handleSuccessInner = () => {
  clickType.value = 'success'
  dialogVisible.value = false
}

const handleCancelInner = (_cancelType: string) => {
  clickType.value = 'cancel'
  cancelType.value = _cancelType
  dialogVisible.value = false
}

const closedHandle = () => {
  if (clickType.value === 'success') {
    props.handleSuccess()
  } else {
    props.handleCancel(cancelType.value)
  }
}
</script>

<style scoped lang="scss">
.qr-dialog {
  .content-title{
    text-align:center;
    font-family: Microsoft YaHei, Microsoft YaHei;
    font-weight: bold;
    font-size: 16px;
    color: #192655;
  }
  .content-img{
    width:200px;
  }
  .content{
    display: flex;
    gap:20px;
    flex-direction: column;
    align-items: center;
    justify-content: center;
  }
}
</style>
